package com.realtyreg.config;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.util.CollectionUtils;

import java.util.Map;

/**
 * Created by Petro 05.01.13 18:58
 */
public class SystemPropertyInitializingBean implements InitializingBean {
    /** Properties to be set */
    private Map<String, Object> systemProperties;

    /** Sets the system properties */
    public void afterPropertiesSet() throws Exception {
        if (CollectionUtils.isEmpty(systemProperties)) {
            // No properties to initialize
            return;
        }

        for (String key : systemProperties.keySet()) {
            String value = (String) systemProperties.get(key);

            System.setProperty(key, value);
        }
    }

    public void setSystemProperties(Map<String, Object> systemProperties) {
        this.systemProperties = systemProperties;
    }
}
